package com.example.tuike.service;

import com.example.tuike.entity.UserArticles;
import com.example.tuike.mapper.UserArticlesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*** @Author supersaiya
 * @Description TODO

 * @Date 2025/2/2 21:17

 * @Version 1.0*/
@Service
public class UserArticlesService {

    @Autowired
    private UserArticlesMapper userArticlesMapper;

    public List<UserArticles> getAllUserArticles() {
        return userArticlesMapper.findAll();
    }

    public UserArticles getUserArticleById(Long userArticleId) {
        return userArticlesMapper.findById(userArticleId);
    }

    public UserArticles createUserArticle(UserArticles userArticle) {
        userArticlesMapper.insert(userArticle);
        return userArticle;
    }

    public UserArticles updateUserArticle(UserArticles userArticle) {
        userArticlesMapper.update(userArticle);
        return userArticle;
    }

    public void deleteUserArticle(Long userArticleId) {
        userArticlesMapper.delete(userArticleId);
    }
}